<%@ page import="camuyen.ltwlibrary.util.ServletUtil" %>
<%@ page import="camuyen.ltwlibrary.model.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java"
         pageEncoding="UTF-8"%>
<% if (session.getAttribute("isLoggedIn") == null) {
    String message = (String) session.getAttribute("loginMessage");
    session.setAttribute("loginMessage", null);
    if (message == null) message = "";
%>
<div class="login-form-container navbar-right" style="margin-top: 54px;">
    <form class="login-form navbar-form" action="${pageContext.request.contextPath}/AuthorizerServlet" method="post">
        <span class="message" style="color: #ff0000"><%=message %></span>
        <div class="form-group">
            <input name="username" type="text" class="form-control" placeholder="Username">
        </div>
        <div class="form-group">
            <input name="password" type="password" class="form-control" placeholder="Password">
        </div>
        <button type="submit" class="btn btn-default">Login</button>
    </form>
</div>
<% } else if (ServletUtil.isLoggedIn(session)) {
    User loggedInUser = (User) session.getAttribute("loggedInUser");
%>
<div class="navbar-right" style="margin-top: 54px;">
    <%=loggedInUser.getUsername() %> - <a href="LogoutServlet">Logout</a>
</div>
<% } %>